import Layout from "@/pages/Layout";
import Login from "@/pages/Login";
import { createBrowserRouter } from "react-router-dom";
import { AuthRoute } from "@/components/AuthRoute";

import { Suspense, lazy } from "react";

//1.lazy函数对组件进行导入
//2.配置路由实例


const Home =lazy(()=>import("@/pages/Home") );
const Artcile=lazy(()=>import("@/pages/Article")) ;
const Publish =lazy(()=>import("@/pages/Publish")) ;



const router = createBrowserRouter([
  {
    path: "/",
    element: (
      <AuthRoute>
        <Layout />
      </AuthRoute>
    ),
    children: [
      { index: "true", element: <Suspense><Home /></Suspense> },
      {
        path: "article",
        element: <Suspense><Artcile /></Suspense>,
      },
      {
        path: "publish",
        element: <Suspense><Publish /></Suspense>,
      },
    ],
  },
  {
    path: "/login",
    element: <Login />,
  },
]);
export default router;
